//
//  PaymentConfirmViewController.m
//  KiklinkApp
//
//  Created by LJC on 14/10/24.
//  Copyright (c) 2014年 Kiklink. All rights reserved.
//

#import "PaymentConfirmViewController.h"

#import "ImagesManager.h"
#import "UIColor+hex.h"

#import "MeViewController.h"
#import "PaySuccessViewController.h"

@interface PaymentConfirmViewController ()
{
    ImagesManager *imagesManager;
    NSInteger check;
}
@end

@implementation PaymentConfirmViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"确认支付";
    self.view.backgroundColor = [UIColor colorWithHexString:AppColor_BackGround];
    check = 0;
    
    
    //BundleImages
    imagesManager = [ImagesManager sharedImagesManager];
    
    
    //leftNavItem
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [backButton setFrame:CGRectMake(0, 0, NavBarHeight/4, NavBarHeight/2)];
    [backButton setBackgroundImage:[imagesManager back] forState:UIControlStateNormal];
    [backButton setBackgroundImage:[imagesManager backTapped] forState:UIControlStateHighlighted];
    [backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftNavBarItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftNavBarItem;
    
    
    //cost
    self.costLabel.text = self.cost;
    
    
    //payStyle
    [self.payBtn1 addTarget:self action:@selector(payBtn1Action) forControlEvents:UIControlEventTouchUpInside];
    [self.payBtn2 addTarget:self action:@selector(payBtn2Action) forControlEvents:UIControlEventTouchUpInside];
    [self.payBtn3 addTarget:self action:@selector(payBtn3Action) forControlEvents:UIControlEventTouchUpInside];
    
    
    //goPay
    [self.goPay.layer setCornerRadius:5];
    [self.goPay addTarget:self action:@selector(goPayAction) forControlEvents:UIControlEventTouchUpInside];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - back
- (void)back
{
    [self.navigationController popToRootViewControllerAnimated:NO];
    UITabBarController *tabBar = (UITabBarController *)self.view.window.rootViewController;
    tabBar.selectedIndex = 3;
    UINavigationController *meNAV = [tabBar.viewControllers objectAtIndex:3];
    MeViewController *meVC = (MeViewController *)[meNAV.viewControllers objectAtIndex:0];
    [meVC pushToUnpay];
}
#pragma mark - back End

#pragma mark - payBtnAction
- (void)payBtn1Action
{
    self.check1.image = [imagesManager check];
    self.check2.image = [imagesManager unCheck];
    self.check3.image = [imagesManager unCheck];
    check = 1;
}
- (void)payBtn2Action
{
    self.check1.image = [imagesManager unCheck];
    self.check2.image = [imagesManager check];
    self.check3.image = [imagesManager unCheck];
    check = 2;
}
- (void)payBtn3Action
{
    self.check1.image = [imagesManager unCheck];
    self.check2.image = [imagesManager unCheck];
    self.check3.image = [imagesManager check];
    check = 3;
}
#pragma mark - payBtnAction End

#pragma mark - goPayAction
- (void)goPayAction
{
    switch (check) {
        case 1:
            NSLog(@"支付宝");
            break;
        case 2:
            NSLog(@"银联");
            break;
        case 3:
            NSLog(@"微信");
            break;
        default:
            break;
    }
    
    PaySuccessViewController *paySuccessVC = [[PaySuccessViewController alloc] init];
    [self.navigationController pushViewController:paySuccessVC animated:YES];
}
#pragma mark - goPayAction End

@end
